<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>"i新浪微博”选项设置</title>
    <link rel="stylesheet" type="text/css" href="main.css" />
    <script type="text/javascript" src="json2.js"></script>
    
    <script type="text/javascript">
        var defaultNoLimit = false;
        var defaultNoLimit = false;
        var defaultBigPic = true;
        var defaultSendToSina = true;
        var defaultAd = true;
        var defaultDraft = false;
        var defaultOptions = "{\"hide\":false,\"draft\":false, \"bigPic\":false, \"nolimit\":false, \"ad\": false, \"sendToSina\": false, shortcut:false}";
        var defaultHide = "{\"admin\":{\"right\":[]}, \"profile\":{\"right\":[]}}";

        function restore_options() {
            var options = JSON.parse(getLocalStorageVal('options', defaultOptions));
            
            document.getElementById("hide").checked = options.hide === true;
        	document.getElementById("nolimit").checked = options.nolimit === true;
	        document.getElementById("bigPic").checked = options.bigPic === true;
	        document.getElementById("sendToSina").checked = options.sendToSina === true;
	        document.getElementById("ad").checked = options.ad === true;
	        document.getElementById("draft").checked = options.draft === true;
	        document.getElementById("shortcut").checked = option.shortcut === true;
        }
        
        function save_options() {
            var opt = {
                'hide':document.getElementById('hide').checked,
                'nolimit':document.getElementById("nolimit").checked,
                'bigPic':document.getElementById("bigPic").checked,
                'sendToSina':document.getElementById("sendToSina").checked,
                'ad':document.getElementById("ad").checked,
                'draft':document.getElementById("draft").checked,
                'shortcut':document.getElementById("shortcut").checked
            };
            
            localStorage['options'] = JSON.stringify(opt);
            if(!opt.hide)
            {
                localStorage['hide'] = defaultHide;
            }
            
            showSaved();
        }
        
        function resetOptions(){
            document.getElementById('hide').checked = false;
            document.getElementById("nolimit").checked = false;
	        document.getElementById("bigPic").checked = false;
	        document.getElementById("sendToSina").checked = false;
	        document.getElementById("ad").checked = false;
	        document.getElementById("draft").checked = false;
	        document.getElementById("shortcut").checked = false;
            localStorage['options'] = JSON.stringify(JSON.parse( defaultOptions));
            localStorage['hide'] = JSON.stringify(JSON.parse(defaultHide));
            
            showSaved();
        }
        
        function show()
        {
            localStorage['hide'] = JSON.stringify(JSON.parse(defaultHide));
        }
        
        function showSaved() {
            document.getElementById("status").innerHTML = "啊啊，成功";
            setTimeout(function () {
                document.getElementById("status").innerHTML = "";
            }, 750);
        }

    function getLocalStorageVal(key, defaultVal) {
        var val = localStorage[key];
        if (val == undefined || val == null) {
            localStorage[key] = defaultVal;
            return defaultVal;
        } else {
            return localStorage[key]
        }
    }
    </script>

    </head>
<body onload="restore_options();" class="options">
    <div id="optionsView" class="vignette">
        <div class="vignetteContent">
            <div id="optionsHeader">
                <img src="logo.png" />
            </div>
            <form name="optionsForm" class="optionsForm" action="#">
            <div id="optionsContainer">
                <h2 message="options_title">
                    “我的新浪微博”</h2>
                <table class="simpleOptions">
                   <tr id="Tr1">
                        <td>
                            启动隐藏微博主页右边项功能<br />
                            </td>
                        <td>
                            <input id="hide" type="checkbox" />（选中该项后，去微博主页右边点“<font style="color:Red;">隐藏</font>”两字）
                              </td>
                    </tr>
                    <tr id="autoSaveContainer">
                        <td>
                            自动将任意长微博分为多条发送，不受140字限制</td>
                        <td>
                            <input id="nolimit" type="checkbox" />（测试版）</td>
                    </tr>
                    <tr id="autoSaveContainer">
                        <td>
                            默认显示大图片：
                        </td>
                        <td>
                            <input id="bigPic" type="checkbox"  />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            将网页分享到“新浪微博”：
                        </td>
                        <td>
                            <input id="sendToSina" type="checkbox"  />（修改该项，Chrome重启后起作用）
                        </td>
                    </tr>
                    <tr>
                        <td>
                            关闭发微薄的文本框下方那个新浪活动的广告</td>
                        <td>
                            <input id="ad" type="checkbox"  /></td>
                    </tr>
                    <tr>
                        <td>
                            保存草稿</td>
                        <td>
                            <input id="draft" type="checkbox"/></td>
                    </tr>
                    <tr>
                        <td>
                            微博快捷键</td>
                        <td>
                            <input id="shortcut" type="checkbox"/>（快捷键说明在主页按g和数字0键弹出）</td>
                    </tr>
                </table>
            </div>
            &nbsp;<input id="save" value="保存设置" type="button" onclick="save_options();" />
            &nbsp;<input id="reset" type="button" value="恢复到不用插件那样" onclick="resetOptions();" />
            <span id="status" style="color:Red"></span>
            &nbsp; 
            </form>
        </div>
    </div>
    <div class="copyright" message="copyright">
    <a href="http://t.sina.com.cn/airbai">联系作者</a>
    </div>
</body>
</html>
